/**
 * 本地存储
 * @module Store
 */

let Store = {
  get: function (key) {
    var value = wx.getStorageSync(key);
    if (value) {
      try {
        var value_json = JSON.parse(value);
        if (typeof value_json === 'object') {
          return value_json;
        } else if (typeof value_json === 'number') {
          return value_json;
        }
      } catch (e) {
        return value;
      }
    } else {
      return false;
    }
  },
  set: function (key, value) {
    wx.setStorageSync(key, value);
  },
  remove: function (key) {
    wx.removeStorageSync(key);
  },
  clear: function () {
    wx.clearStorage();
  }
};


export default Store;
